﻿<Page
    x:Class="ImageBinding.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ImageBinding"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:localData="using:ImageBinding.DataModel"
    xmlns:localConverters="using:ImageBinding.Converters">
    <Page.Resources>
        <localData:DataSource x:Key="mainDataSource"></localData:DataSource>
        <CollectionViewSource Source="{Binding Path=Items, Source={StaticResource mainDataSource}}"
                              x:Key="mainView"></CollectionViewSource>
        <localConverters:StreamToBitmapConverter x:Key="bitmapConverter"/>
        <DataTemplate x:Key="DataTemplate">
            <Grid Width="150">
                <Grid.RowDefinitions>
                    <RowDefinition Height="70"/>
                    <RowDefinition Height="32"/>    
                </Grid.RowDefinitions>
                <Image Grid.RowSpan="2" Source="{Binding Thumbnail, 
                    Converter={StaticResource bitmapConverter}}"></Image>
                <Border Grid.Row="1" Background="#80000000" Padding="5">
                    <TextBlock Text="{Binding Name}" VerticalAlignment="Center" 
                               TextTrimming="WordEllipsis" />
                </Border>
            </Grid>
        </DataTemplate>
    </Page.Resources>
    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" 
        DataContext="{StaticResource mainDataSource}">
        <GridView
            Margin="0 90 0 0" ItemsSource="{Binding Source={StaticResource mainView }}" 
                  ItemTemplate="{StaticResource DataTemplate}" SelectionMode="None">
        </GridView>
    </Grid>
</Page>
